import request from "../index";
import { version } from "@/config";

/*
* 优惠券
*/
// 优惠券列表
export function couponList (data){
    return request({
        url:`/ssop/api/promotions-v${version}/coupon/user/have`,
        method:"get",
        params: data
    })
}

// 领取优惠券 data -> Array
export function receiveCoupon(data) { 
    return request({
        url:`/ssop/api/promotions-v${version}/coupon/user/receive/batch`,
        method:"post",
        data: data
    })
}

// 根据商品id，查询是否有优惠券可用
export function haveCoupons (data){
    return request({
        url:`/ssop/api/promotions-v${version}/applets/activity/use/list/size`,
        method:"post",
        data: data
    }) 
}

// 查询某商品，是否有可用优惠券
export function haveCouponsList (data){
    return request({
        url:`/ssop/api/promotions-v${version}/applets/activity/use/list`,
        method:"post",
        data: data
    })
}

// 发放优惠券
export function sendCoupon() { 
    return request({
        url:`/ssop/api/promotions-v${version}/user/coupon/send`,
        method:"get"
    })
}

// 根据商品id，获取可用优惠券
export function getCouponByGoodsID(data) { 
    return request({
        url:`/ssop/api/promotions-v${version}/applets/activity/goods/coupons`,
        method:"post",
        data
    })
}

// 获取活动详情
export function getActivityDetail(id) { 
    return request({
        url:`/ssop/api/goods-v${version}/applet/goods/list/channel?activityId=${id}`,
        method:"get"
    })
}

// 获取活动规则
export function getActivityRule(id) { 
    return request({
        url:`/ssop/api/promotions-v${version}/applets/activity/rule/description?activityBaseId=${id}`,
        method:"get"
    })
}